Mapa de situación de los Gobiernos Regionales
library(rio)
## The following rio suggested packages are not installed: 'csvy', 'feather', 'fst', 'hexView', 'readODS', 'rmatio'
## Use 'install_formats()' to install them
##
## Attaching package: 'rio'
## The following object is masked from 'package:plotly':
##
## export
library(sp)
library(geojsonio)
##
## Attaching package: 'geojsonio'
## The following object is masked from 'package:devtools':
##
## lint
## The following object is masked from 'package:base':
##
## pretty
library(rgdal)
## rgdal: version: 1.4-8, (SVN revision 845)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.2, released 2017/09/15
## Path to GDAL shared files: /usr/share/gdal/2.2
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
## Path to PROJ.4 shared files: (autodetected)
## Linking to sp version: 1.4-1
library(spdep)
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge package with:
## `install.packages('spDataLarge', repos='https://nowosad.github.io/drat/', type='source')`
library(pgirmess)
library(gstat)
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
library(rgeos)
## rgeos version: 0.5-2, (SVN revision 621)
## GEOS runtime version: 3.5.1-CAPI-1.9.1
## Linking to sp version: 1.4-1
## Polygon checking: TRUE
library(gtable)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
library(ggplot2)
library(rgdal)
library(maptools)
## Checking rgeos availability: TRUE
library(Matrix)
##
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
library(LearnBayes)
##
## Attaching package: 'LearnBayes'
## The following object is masked from 'package:igraph':
##
## sir
library(spatstat)
## Loading required package: spatstat.data
## Loading required package: nlme
##
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
##
## collapse
## Loading required package: rpart
## Registered S3 method overwritten by 'spatstat':
## method from
## print.boxx cli
##
## spatstat 1.63-3 (nickname: 'Wet paint')
## For an introduction to spatstat, type 'beginner'
##
## Note: R version 3.6.0 (2019-04-26) is more than a year old; we strongly recommend upgrading to the latest version
##
## Attaching package: 'spatstat'
## The following object is masked from 'package:scales':
##
## rescale
## The following object is masked from 'package:gstat':
##
## idw
## The following objects are masked from 'package:igraph':
##
## diameter, edges, is.connected, vertices
## The following object is masked from 'package:data.table':
##
## shift
library(googleVis)
## Creating a generic function for 'toJSON' from package 'jsonlite' in package 'googleVis'
##
## Welcome to googleVis version 0.6.4
##
## Please read Google's Terms of Use
## before you start using the package:
## https://developers.google.com/terms/
##
## Note, the plot method of googleVis will by default use
## the standard browser to display its output.
##
## See the googleVis package vignettes for more details,
## or visit https://github.com/mages/googleVis.
##
## To suppress this message use:
## suppressPackageStartupMessages(library(googleVis))
library(plyr)
## ----------------------------------------------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ----------------------------------------------------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following object is masked from 'package:maps':
##
## ozone
## The following objects are masked from 'package:plotly':
##
## arrange, mutate, rename, summarise
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise, summarize
## The following object is masked from 'package:purrr':
##
## compact
library(maptools)
library(leaflet)
##
## Attaching package: 'leaflet'
## The following object is masked from 'package:networkD3':
##
## JS
library(htmlwidgets)
##
## Attaching package: 'htmlwidgets'
##
## The following object is masked from 'package:networkD3':
##
## JS
library(devtools)
dep <- readOGR(dsn="/cloud/project/Mapa_Covid",layer="gadm36_PER_1")
## OGR data source with driver: ESRI Shapefile
## Source: "/cloud/project/Mapa_Covid", layer: "gadm36_PER_1"
## with 26 features
## It has 10 fields
datos_regional1="https://docs.google.com/spreadsheets/d/e/2PACX-1vQkc4tZ-ZXIUtZ6CZPEarncXxE3lFMD8Tp4MahTcc-hMw2XdAbn5nSPLFwvM-6YoAv3l05t9ggK0bv-/pub?gid=1241161277&single=true&output=csv"
datos_regional1<-as.data.frame(read.csv(datos_regional1))
mapacondata=merge(dep,datos_regional1)#merge de la base con el mapa
popup <- paste0("<b>", "Región: ", "</b>", as.character(mapacondata$DEPARTAMEN), "<br>",
"<b>", "Presupesto Ejecutado: ", "</b>", as.character(mapacondata$presupuesto_covid_mapa), "<br>",
"<b>", "Casos Positivos: ", "</b>", as.character(mapacondata$casos_positivos), "<br>",
"<b>", "Muestras: ", "</b>", as.character(mapacondata$muestras_regionales), "<br>")
palfac <- colorFactor(palette=c("#fee0d2","#fc9272","#de2d26"), domain = mapacondata$casos_pruebas_mapa_categorias)
mapa <- leaflet(mapacondata) %>% addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5, opacity = 1,
fillOpacity = 0.5, fillColor = ~palfac(mapacondata$casos_pruebas_mapa_categorias), group = "Belleza",
highlightOptions = highlightOptions(color = "white", weight = 2, bringToFront = TRUE),
label = ~mapacondata$DEPARTAMEN, labelOptions = labelOptions(direction = "auto"), popup = popup) %>%
addLegend(position = "topright", pal = palfac, values = ~mapacondata$casos_pruebas_mapa_categorias,
title = "% de casos positivos por región")
mapa
#<p><img src="subnacional_files/figure-html/mapa_interactivo.PNG" /><!-- --></p>
#Para conocer la situación a nivel regional: [Mapa interactivo de Gobiernos Regionales](casos_files/figure-html/mapa.html)
Datos actualizados al 03/05/2020. Mapa elaborado por Manuel Ponte.